feat: polyglot script engine for code-based load testing#36
Merged
Conversation
Add `kar script` command supporting multiple languages: - Starlark (.star) - Python-like, built-in, goroutine-safe - JavaScript (.js) - ES5+ via goja, built-in - External process protocol (.py, .rb, .lua) - JSON-line IPC Key features: - chaos() primitive as first-class API (unique to kar98k) - VU scheduling with ramp stages - Checks and thresholds with pass/fail reporting - think_time() for chaos-aware delays - setup/teardown lifecycle hooks - Detailed test report with latency percentiles Architecture: - Runner interface for polyglot backend support - VUScheduler for virtual user lifecycle management - Auto-detect language from file extension Signed-off-by: rlaope <piyrw9754@gmail.com>
Replace fmt.Println with fmt.Print for strings containing newlines. Signed-off-by: rlaope <piyrw9754@gmail.com>
6b85d71 to
4353361
Compare
- Fix nil body reader crash in newHTTPRequest - Add mutex for goroutine-safe external process communication - Fix chaos config preset parsing for external runners - Add Python example script using JSON-line protocol Signed-off-by: rlaope <piyrw9754@gmail.com>
- Python SDK (sdk/python/kar98k.py) wraps JSON-line protocol - Users write natural Python: http.get(), check(), sleep() - SDK auto-starts protocol loop via atexit - External runner now sends HTTP responses back to scripts - Example: examples/basic_test.py using SDK Signed-off-by: rlaope <piyrw9754@gmail.com>
- Python SDK (sdk/python/kar98k.py): from kar98k import http, check - Ruby SDK (sdk/ruby/kar98k.rb): require 'kar98k' - External runner sends HTTP responses back to scripts - Both SDKs auto-start protocol loop via atexit/at_exit - Verified: Python 3.x and Ruby 2.6+ compatible Signed-off-by: rlaope <piyrw9754@gmail.com>
- Web dashboard at localhost:8888 with --dashboard flag - SSE-based real-time stats streaming (1s interval) - Sky blue + black theme matching CLI aesthetic - Live RPS and latency charts (Canvas-based, no dependencies) - Real-time checks, status codes, error rate display - Single HTML file embedded in Go binary Signed-off-by: rlaope <piyrw9754@gmail.com>
- Clean Locust-style dashboard: data-focused, no visual clutter - Top stat bar, dual charts, side panels for checks/status codes - Add Script Engine section to README with polyglot examples Signed-off-by: rlaope <piyrw9754@gmail.com>
- Add --wait flag: dashboard shows Start button, test waits for trigger
- Add Start/Stop buttons to dashboard UI
- Add /api/start, /api/stop, /api/state endpoints
- Add peak tracking for RPS, latency, P95, VUs
- Add RPS history panel with spike detection (>1.5x avg)
- Add descriptions to each chart and panel explaining what metrics mean
- Two modes: kar script test.star --dashboard (auto-run)
kar script test.star --dashboard --wait (trigger from UI)
Signed-off-by: rlaope <piyrw9754@gmail.com>
- Stop after test shows Start button again for re-run - --wait mode loops: Start → Run → Stop → Start → ... - Process stays alive between runs in --wait mode - Non-wait mode unchanged (runs once) Signed-off-by: rlaope <piyrw9754@gmail.com>
- 10% chance: 500 error + 1~3s delay - 5% chance: 400 bad request - 3% chance: slow response (200~700ms, no error) - Applied to /health, /api/users list, /api/echo Signed-off-by: rlaope <piyrw9754@gmail.com>
Signed-off-by: rlaope <piyrw9754@gmail.com>
rlaope
added a commit
that referenced
this pull request
Apr 5, 2026
feat: polyglot script engine for code-based load testing
rlaope
added a commit
that referenced
this pull request
Apr 5, 2026
feat: polyglot script engine for code-based load testing
rlaope
added a commit
that referenced
this pull request
Apr 5, 2026
feat: polyglot script engine for code-based load testing
rlaope
pushed a commit
that referenced
this pull request
Apr 5, 2026
feat: polyglot script engine for code-based load testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kar scriptcommand for code-based load testing with kar98k's chaos patternschaos()as first-class API primitive — unique differentiator vs k6/Locust/GatlingHow it works
Example (.star)
Verified
Test plan